package com.demo.juc.locks;

import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @Author: shubin_yao
 * @Date: 2022/05/08/16:51
 *  可重入锁: 同步方法访问同步方法
 *
 */
public class ReLock {

    public static void main(String[] args) {

        M m = new M();
        for (int i = 0; i < 2; i++) {
            new Thread(()->{
                m.m1();
            },String.valueOf(i)).start();
        }

        ReentrantReadWriteLock readWriteLock  = new ReentrantReadWriteLock();
        ReentrantReadWriteLock.ReadLock readLock = readWriteLock.readLock();
        ReentrantReadWriteLock.WriteLock writeLock = readWriteLock.writeLock();
    }

}
